<template>
  <div class='app-container'>
    <div class="_list" style="margin-top: 15px">
      <el-table highlight-current-row ref="tableRow" @selection-change="handleSelectionChange" :data="dataList" style="width: 100%" v-loading.body="listLoading">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column label="用户头像" width="180">
          <template slot-scope="scope">
            <div class="user_info">
              <span class="thumbnail"><img :src="scope.row.avatar"></span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="用户昵称">
          <template slot-scope="scope">
            {{scope.row.nickname}}
          </template>
        </el-table-column>
        <el-table-column label="地区">
          <template slot-scope="scope">
            {{scope.row.province +'-'+ scope.row.city}}
          </template>
        </el-table-column>
        <el-table-column label="加入时间">
          <template slot-scope="scope">
            {{scope.row.createdAt | formatDate}}
          </template>
        </el-table-column>
        <el-table-column label="最后一次登录时间">
          <template slot-scope="scope">
            {{scope.row.lastLogin | formatDate}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="180">
          <template slot-scope="scope">
            <to-link :val="'uAJOy0w9_'" @to="handleDelete(scope.row)">
              <el-button size="small" type="primary">删除</el-button>
            </to-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pages">
      <div class="left">
        <el-tooltip class='item' effect='dark' content='批量删除' placement='top'>
          <el-button @click="handleAll" size="small" type="danger">批量删除</el-button>
        </el-tooltip>
      </div>
      <div class="right" v-if="total>0">
        <el-pagination @current-change="handleCurrentChange" background :current-page.sync="page" layout="total, prev, pager, next" :total="total">
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script lang="babel">
import mixinsTable from '@/utils/mixins.table'
export default {
  name: 'userList',
  mixins: [mixinsTable],
  data() {
    return {
      servicePath: '/user/userList'
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleCurrentChange(val) {
      this.getList(val)
    },
    initForm(row) {
      this.$set(this.form, '_id', row._id)
      this.$set(this.form, 'username', row.username)
      this.form.power = row.power._id
    },
    FormClear() {
      this.$set(this.form, 'username', '')
      this.$set(this.form, 'password', '')
      this.$set(this, 'apassword', '')
    }
  }
}

</script>
<style lang="scss">
.el-table {
  .warning-row {
    background-color: #f3f3f3;
    color: #C3BFBF
  }
}
.user_info {
  .thumbnail {
    width: 60px;
    height: 60px;
    float: left;
    img {
      width: 60px;
      height: 60px;
    }
  }
  .info {
    overflow: hidden;
    padding-left: 10px;
  }
}

</style>
